package com.gym.myshop.dao.impl;

import com.gym.myshop.dao.TypeDao;
import com.gym.myshop.entity.Type;

import com.gym.myshop.util.DBUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

/**
 * @author ming
 * 2021/11/6
 * description:商品分类
 */
public class TypeDaoImpl implements TypeDao {

    private QueryRunner qr = new QueryRunner();

    //查全部
    @Override
    public List<Type> getAll() {
        try {
            return qr.query(DBUtil.getConnection(),
                    "select * from type",new BeanListHandler<>(Type.class));
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
